package com.leyou.item.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leyou.item.dto.SkuDTO;
import com.leyou.item.entitry.Sku;
import com.leyou.item.mapper.SkuMapper;
import com.leyou.item.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements SkuService {

    @Autowired
    private  SkuMapper skuMapper;


    @Override
    public List<SkuDTO> listSkuByIds(List ids) {
        List selectBatchIds = this.skuMapper.selectBatchIds(ids);

        return  SkuDTO.convertEntityList(selectBatchIds);
    }

    @Override
    public List<SkuDTO> listSkuBySpuId(Long id) {
        List<Sku> listSkuBySpuIdList = this.skuMapper.selectList(new QueryWrapper<Sku>().eq("spu_id", id));

        return SkuDTO.convertEntityList(listSkuBySpuIdList);
    }
}